package jdbctest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by Administrator on 2017/9/11.
 */
/**
 * 功能：把加载驱动和数据库连接封装起来
 * */
public class ConnectionUtils {
    //静态
    public static Connection getConnection(){
        try {
            //1.加载驱动
            Class.forName("com.mysql.jdbc.Driver");
            //2.连接数据库
            Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3307/jdbc","root","123456");
            return conn;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
